package monq.main;

import java.io.BufferedInputStream;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class MqImages {
	private static final int[][] rectID = {
		{
			R.drawable.btn_black,
			R.drawable.btn_black1
		},{
			R.drawable.btn_green,
			R.drawable.btn_green1,
			R.drawable.btn_green2,
			R.drawable.btn_green3,
			R.drawable.btn_green4,
			R.drawable.btn_green5,
			R.drawable.btn_green6,
			R.drawable.btn_green7,
			R.drawable.btn_green8,
			R.drawable.btn_green9,
			R.drawable.btn_green10
		},{
			R.drawable.btn_blue,
			R.drawable.btn_blue1,
			R.drawable.btn_blue2,
			R.drawable.btn_blue3,
			R.drawable.btn_blue4,
			R.drawable.btn_blue5,
			R.drawable.btn_blue6,
			R.drawable.btn_blue7,
			R.drawable.btn_blue8,
			R.drawable.btn_blue9,
			R.drawable.btn_blue10
		},{
			R.drawable.btn_red,
			R.drawable.btn_red1,
			R.drawable.btn_red2,
			R.drawable.btn_red3,
			R.drawable.btn_red4,
			R.drawable.btn_red5,
			R.drawable.btn_red6,
			R.drawable.btn_red7,
			R.drawable.btn_red8,
			R.drawable.btn_red9,
			R.drawable.btn_red10
		},{
			R.drawable.btn_yellow,
			R.drawable.btn_yellow1,
			R.drawable.btn_yellow2,
			R.drawable.btn_yellow3,
			R.drawable.btn_yellow4,
			R.drawable.btn_yellow5,
			R.drawable.btn_yellow6,
			R.drawable.btn_yellow7,
			R.drawable.btn_yellow8,
			R.drawable.btn_yellow9,
			R.drawable.btn_yellow10
		}
	};
	
	private static final int cheerMessageID=
			R.drawable.cheermsg_9
	;

	private static Bitmap[][] rectBitmap = null;
	private static Bitmap cheerMessageBitmap[] = null;
	
	public static final int BLACK =0; 
	public static final int GREEN =1; 
	public static final int BLUE =2; 
	public static final int RED=3; 
	public static final int YELLOW=4; 
	
	private static final int COLORS = 5;
	private static final int cheerMessages = 1;

	public MqImages(){
	}
	
	MqImages makeBitmap (){
		if (rectBitmap == null){
			rectBitmap = new Bitmap[COLORS][];
			
			for (int i=0;i<COLORS;i++){
				rectBitmap[i] = new Bitmap[rectID[i].length];
				for (int j=0; j<rectBitmap[i].length; j++){
					rectBitmap[i][j] = BitmapFactory.decodeResource(GameCtrl.getResources(), rectID[i][j]);
				}
			}
		}
		
		if(cheerMessageBitmap == null){
			cheerMessageBitmap = new Bitmap[cheerMessages];
			for (int i=0; i< cheerMessages; i++){
				cheerMessageBitmap[i] = BitmapFactory.decodeResource(GameCtrl.getResources(), cheerMessageID);
			}
		}		
		return this;
	}
	
	Bitmap getBitmap(int cellColor, int number){
		Bitmap ret=null;
		
		switch (cellColor){
		case BLACK:
			ret = rectBitmap[cellColor][0];
			break;
		case GREEN:
		case BLUE:
		case RED:
		case YELLOW:
			ret = rectBitmap[cellColor][number];
			break;
		}		
		return ret;
	}
	
	static int getId (int cellColor, int number){
		int ret=0;
		
		switch (cellColor){
		case BLACK:
			ret = rectID[cellColor][0];
			break;
		case GREEN:
		case BLUE:
		case RED:
		case YELLOW:
			ret = rectID[cellColor][number];
			break;
		}		
		return ret;
	}
	Bitmap getBitmap(int msgNo){
		return cheerMessageBitmap[msgNo];
	}
}
